<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<!DOCTYPE HTML>
<html>
	
  <head>
    
    <title>选择商品</title>
    


<style>
	<!--
	table {
	table-layout: fixed;
	word-wrap:break-word;
	}
	td{
		
		word-break:break-all;
	}
	
	}
	//-->
</style>
<link rel="stylesheet" type="text/css" href="<%=basePath %>/css/manual.css">

  </head>
  <base target="_self"></base>
  <body>
    <table  width="100%"  border="0" cellpadding="0" cellspacing="0" height="100%">
  	
  	<tr valign="top">
  		<td>
  			<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  
 <tr>
    	
    	<td width="100%">
    		<FONT size="6">选择商品</FONT> 
    		
    		
    	</td>
    </tr>
    
    <tr>
    	
     	
     	
     	<td valign="top" >
     <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
    	 <tr>
     		<td>
     	<table width="100%" height="100%" border="0" cellpadding="0" bgcolor="#e5f3ff" cellspacing="0" style= "border:1px solid #ffffff; border-top-color:#6cb1f1;">
     		
     		<tr>
     			<td>商品信息
     			<input type="button" value="查看谁有权限" 
     				onclick="javascript:openUrlForDialog('selectoperatorlimitedAction_background.action?limitedCode=<s:property value="limitedcode"/>')"/>
     			</td>
     		</tr>
     	</table>
     	</td>
     		</tr>
 <tr>
     		<td>
    	
			<table  border="0" >
				<tr>
				  <td>
					  查找产品:<input type="text" name="searchStr" id="searchStr" size="30" value="<s:property value="searchStr"/>"/>
					  <input type="button" onclick="javascript:openUrlForDialog('insertgoodsinfo_warehouse.action?searchStr='+$('#searchStr').attr('value'))" value="查找" />
					  
				  </td>
			  </tr>
			</table>
	</td>
     		</tr>
     		 <tr>
     		<td>
     		
		<table align="left"  border="0"  cellspacing="0" cellpadding="0" style= "border:1px solid #ffffff; border-bottom-color:#21a4dc;
    border-left-color:#21a4dc;border-right-color:#21a4dc;border-top-color:#21a4dc">
    
   	<s:iterator id="goodsList" value="goodsList" status="sta">
   		<tr>
   			<td width="105"><s:property value="#goodsList.id_goods"/></td>
   			<td>
   				<a href="javascript:insertGoods('<s:property value="#goodsList.id_goods"/>'+','+'<s:property value="#goodsList.name_goods"/>');">
   					<s:property value="#goodsList.name_goods"/>
   				</a>
   				
   			</td>
   			<td><button onclick="insertGoods('<s:property value="#goodsList.id_goods"/>'+','+'<s:property value="#goodsList.name_goods"/>');">选择</button></td>
   		</tr>
     		
    </s:iterator>
     		
     		
     	</table>
     	</td>
     	</tr>
     	</table>
     	
     	 <table width="100%" border="0" cellpadding="0" bgcolor="" cellspacing="0" >
				<tr >
					<td >
						<%
						 String url = "insertgoodsinfo_warehouse.action";//*/
						 int pageSize = (Integer) request.getAttribute("pageSize");
							int beginPageNum =  (Integer) request.getAttribute("beginPageNum");
							int countRow =  (Integer) request.getAttribute("rowNum");
						    int countPage =(countRow-1)/pageSize+1;
						    int currentPage = countPage - (countRow-beginPageNum)/pageSize;
						    
						    
						    
						 	 
						    
						    String searchstr = (String)request.getParameter("searchStr");//*/
						    if(searchstr != null){
						    	searchstr = java.net.URLDecoder.decode(searchstr, "UTF-8");
						    	//searchstr = java.net.URLEncoder.encode(searchstr,"UTF-8");
						    	//searchstr = searchstr.replaceAll("%", "%25");
						    }else{
						    	searchstr = "";
						    }
						    
						    if((beginPageNum-pageSize+1) >= 1){%>
					    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum-pageSize) %>">
									上一页 </a>
					   <% }
						    
						    //beginPageNum =  (pageNum - 1) * pageSize;
							StringBuffer chagePageBuff = new StringBuffer();
							if(countPage >= 2){ 
								int begin = currentPage - 9;
								int end = currentPage + 9;
								
								if(begin < 1){
									begin = 0;
								}
								if(end > countPage){
									end = countPage-1;
								}
								
								
								for(int i=begin;i<countPage;i++){
									
									
									
									
									
									if(beginPageNum == i*pageSize){
										%>
										<%=i+1 %>
										<%
									}else{
										%>
										<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=i*pageSize %>">
										[<%=i+1 %>] </a>
										<%
									}
									
									if(i > end){
										
										break;
										
									}
								}
							}
							
							if((beginPageNum+pageSize-countRow) < 0){%>
					    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum+pageSize) %>">
									下一页 </a>
					   		<% }
							if(countPage != 1){%>
				    		<input type="text" size="4" id="goPageNum" name="goPageNum"/> / <%=countPage %> <button onclick="gotoPage();">跳转</button>
					   		<% }
							//*/
							%>
						
					
					</td>

				</tr>
				
	</table>
	</td>
</tr>
</table>
  		
  		</td>
  	</tr>
  </table>

  
  </body>
  <script type="text/javascript">
  	function insertGoods(goodsinfo){

  		
		//alert(goodsname);
		window.returnValue=goodsinfo;
		//window.parent.insertGoods(goodsid,goodsname);
		window.close();
  	}

  	function gotoPage(){
  		countPage = <%=countPage %>;
  		pageSize = <%=pageSize %>;
  		pageNum = document.getElementById("goPageNum").value;

  		pageNum = parseInt(pageNum);
  		if(pageNum > countPage){
  			pageNum = countPage;
  		}
  		beginPageNum = pageNum * pageSize - pageSize;
  		if(beginPageNum < 0){
  			beginPageNum = 0;

  		}
  		if(isNaN(beginPageNum)){
  			beginPageNum = 0;
  		}
  		url = '<%=url %>?searchStr=<%=searchstr %>&beginPageNum=' + beginPageNum;
  		//alert(url);
  		window.location.href=url;
  	}
  </script>
</html>
